package com.myProject.dao;

import com.myProject.bean.TMouse;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface MouseDao {
    @Select("Select * from t_mouse")
    @Results(id = "mouseMap", value = {
            @Result(id = true, column = "pk_id", property = "pkId"),
            @Result(column = "name", property = "name"),
            @Result(column = "food", property = "food"),
            @Result(column = "danger", property = "danger"),
            @Result(column = "breed", property = "breed"),
            @Result(column = "enemy", property = "enemy"),
            @Result(column = "step", property = "step"),
            @Result(column = "picture",property = "picture")
    })
    List<TMouse> getMouseList(TMouse mouse);


    @Select("Select * from t_mouse where name like '%${name}%'")
    @ResultMap("mouseMap")
    List<TMouse> findMouseList(TMouse mouse);


    @Insert("insert into t_mouse (name,food,danger,breed,enemy,step,picture) value (#{name},#{danger},#{danger},#{breed},#{enemy},#{step},#{picture})")
    @SelectKey(
            before = false,keyColumn = "pk_id",keyProperty = "pkId",statement = "select last_insert_id()",resultType = int.class
    )
    int addMouse(TMouse mouse);
}
